<!DOCTYPE html>
<html>
<head>
    <title>Test for Bug 33806: Would like API to disallow setting of document.domain for pages with certain URL schemes</title>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <script>
        if (document.location.hostname == "127.0.0.1") {
            document.location.hostname = "many.subdomains.for.example.test";
        } else {
            test(function () {
                assert_equals(document.domain, window.location.hostname);
            }, "Untouched.");

            test(function () {
                document.domain = 'subdomains.for.example.test';
                assert_equals(document.domain, 'subdomains.for.example.test');
            }, "Touched.")

            test(function () {
                if (window.testRunner)
                    testRunner.setDomainRelaxationForbiddenForURLScheme(true, "http");

                assert_throws_dom("SecurityError", function () {
                    document.domain = 'for.example.test';
                });
                assert_equals(document.domain, 'subdomains.for.example.test');
            }, "Forbid relaxation.");

            test(function () {
                if (window.testRunner)
                    testRunner.setDomainRelaxationForbiddenForURLScheme(false, "http");

                document.domain = 'for.example.test';
                assert_equals(document.domain, 'for.example.test');
            }, "Allow relaxation.");

            test(function () {
                if (window.testRunner)
                    testRunner.setDomainRelaxationForbiddenForURLScheme(true, "not-http");

                document.domain = 'example.test';
                assert_equals(document.domain, 'example.test');
            }, "Forbid relaxation for unrelated scheme.");
        }
    </script>
</head>
<body>
</body>
</html>
